<script setup lang="ts">
import { ref } from 'vue'

interface MenuItem {
  id: number
  mealType: '早餐' | '午餐' | '晚餐'
  date: string
  dishes: string[]
  nutrition: {
    calories: number
    protein: number
    carbs: number
  }
}

const menuItems = ref<MenuItem[]>([
  {
    id: 1,
    mealType: '早餐',
    date: '2024-03-19',
    dishes: ['燕麦粥', '包子', '鸡蛋', '牛奶'],
    nutrition: {
      calories: 450,
      protein: 15,
      carbs: 65
    }
  },
  {
    id: 2,
    mealType: '午餐',
    date: '2024-03-19',
    dishes: ['米饭', '清炒青菜', '红烧鱼', '番茄蛋汤'],
    nutrition: {
      calories: 550,
      protein: 22,
      carbs: 75
    }
  },
  {
    id: 3,
    mealType: '晚餐',
    date: '2024-03-19',
    dishes: ['馒头', '炖排骨', '上海青', '紫菜汤'],
    nutrition: {
      calories: 500,
      protein: 20,
      carbs: 70
    }
  }
])
</script>

<template>
  <div class="dining-management">
    <div class="page-header">
      <div class="header-content">
        <h1>餐饮管理</h1>
        <p class="subtitle">营养均衡的膳食计划</p>
      </div>
      <el-button type="primary" class="add-button">
        <el-icon><Plus /></el-icon>
        添加菜单
      </el-button>
    </div>

    <el-row :gutter="24">
      <el-col :span="8" v-for="item in menuItems" :key="item.id">
        <el-card class="menu-card" shadow="hover">
          <div class="menu-header">
            <div class="meal-info">
              <h3>{{ item.mealType }}</h3>
              <span class="date">{{ item.date }}</span>
            </div>
          </div>

          <div class="menu-content">
            <div class="dishes">
              <h4>菜单</h4>
              <div class="dish-tags">
                <el-tag 
                  v-for="dish in item.dishes" 
                  :key="dish"
                  class="dish-tag"
                  effect="plain"
                >
                  {{ dish }}
                </el-tag>
              </div>
            </div>

            <div class="nutrition-info">
              <h4>营养信息</h4>
              <div class="nutrition-grid">
                <div class="nutrition-item">
                  <span class="label">卡路里</span>
                  <span class="value">{{ item.nutrition.calories }}</span>
                </div>
                <div class="nutrition-item">
                  <span class="label">蛋白质</span>
                  <span class="value">{{ item.nutrition.protein }}g</span>
                </div>
                <div class="nutrition-item">
                  <span class="label">碳水</span>
                  <span class="value">{{ item.nutrition.carbs }}g</span>
                </div>
              </div>
            </div>
          </div>

          <div class="menu-actions">
            <el-button 
              class="action-button edit-button" 
              style="background-color: #ffffff; color: var(--primary-text); border: 1px solid #e4e4e4;"
            >
              编辑菜单
            </el-button>
            <el-button 
              class="action-button view-button"
              style="background-color: #ffffff; color: var(--primary-text); border: 1px solid #e4e4e4;"
            >
              查看详情
            </el-button>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<style scoped lang="scss">
.dining-management {
  .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;

    .header-content {
      h1 {
        font-size: 28px;
        font-weight: 600;
        margin: 0 0 8px;
        color: var(--primary-text);
      }

      .subtitle {
        font-size: 16px;
        color: var(--secondary-text);
        margin: 0;
      }
    }

    .add-button {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 12px 24px;
      font-size: 16px;
    }
  }

  .menu-card {
    margin-bottom: 24px;
    border-radius: 16px;
    background: #ffffff;
    border: none;
    transition: all 0.3s ease;

    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    }

    .menu-header {
      margin-bottom: 24px;

      .meal-info {
        h3 {
          font-size: 24px;
          font-weight: 600;
          margin: 0 0 8px;
          color: var(--primary-text);
        }

        .date {
          color: var(--secondary-text);
          font-size: 14px;
        }
      }
    }

    .menu-content {
      .dishes {
        margin-bottom: 24px;

        h4 {
          font-size: 16px;
          font-weight: 600;
          margin: 0 0 16px;
          color: var(--primary-text);
        }

        .dish-tags {
          display: flex;
          flex-wrap: wrap;
          gap: 8px;

          .dish-tag {
            border-radius: 16px;
            padding: 6px 12px;
            font-size: 14px;
            background: var(--secondary-bg);
            border: none;
            color: var(--primary-text);
          }
        }
      }

      .nutrition-info {
        h4 {
          font-size: 16px;
          font-weight: 600;
          margin: 0 0 16px;
          color: var(--primary-text);
        }

        .nutrition-grid {
          display: grid;
          grid-template-columns: repeat(3, 1fr);
          gap: 16px;

          .nutrition-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
            padding: 12px;
            background: var(--secondary-bg);
            border-radius: 12px;

            .label {
              font-size: 14px;
              color: var(--secondary-text);
              margin-bottom: 4px;
            }

            .value {
              font-size: 20px;
              font-weight: 600;
              color: var(--primary-text);
            }
          }
        }
      }
    }

    .menu-actions {
      display: flex;
      justify-content: flex-end;
      gap: 12px;
      margin-top: 24px;
      padding-top: 24px;
      border-top: 1px solid var(--secondary-bg);

      .action-button {
        padding: 8px 20px;
        font-size: 14px;
        font-weight: 500;
        border-radius: 20px;
        transition: all 0.3s ease;

        &:hover {
          transform: translateY(-1px);
          box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        }
      }
    }
  }
}
</style>